<?php
	class Se extends MY_Model {
		function __construct(){
			parent::__construct();
			$this->load->library('tree');
		}
		
		function getdata($title='',$offset=0,$len=0){
            if($len){
                if($title){
                    $query = $this->db->query('select count(id) as a from c_se where title like "%'.$title.'%"');
                    $pages=$query->result();
                    return isset($pages[0]->a) ? $pages[0]->a : 0;
                }else{
                    $this->db->select('count(*) as a');
                    $this->db->from('se');
                    $pages=$this->db->get('')->result();
                    return isset($pages[0]->a) ? $pages[0]->a : 0;
                }
            }else{
                $page = $this->config->item('page');
                $offset += $page;
                if($title)
                    $query = $this->db->query('select c_se.id,c_se.title,c_se.img,c_se.url,c_se.ipath from c_se join(select id,ipath from c_se where title like "%'.$title.'%") as t on(c_se.id = t.id) limit '.$offset.','.$page);
                else
                    $query = $this->db->query('select id,title,img,url,ipath from c_se limit '.$offset.','.$page);
                return $query->result();
            }
        }
	}